// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'//store
import VueResource from 'vue-resource'
import RestfulPlugin from 'plugins/RestfulPlugin'
import UtilsPlugin from 'plugins/UtilsPlugin'
import DatePlugin from 'plugins/DatePlugin'


Vue.use(VueResource)
Vue.use(RestfulPlugin);
Vue.use(UtilsPlugin);
Vue.use(DatePlugin);




/*=========element-ui BEGAIN=========*/
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-default/index.css'
Vue.use(ElementUI);
/*=========element-ui END=========*/
/*=========主样式 BEGAIN=========*/
import './less/webStyle.less'
/*=========主样式 END=========*/

router.onReady(function(){
  "use strict";
  var loginUserCookie= router.app.$util.readCookie("loginUser");

  if(!loginUserCookie){
    router.push("/loginPage");
  }else{
    var loginUser=JSON.parse(loginUserCookie);
    RestfulPlugin.rsClient.setHeader(loginUser.token);
    router.app.$store.commit("LOGIN_SUCCESS",loginUser);
  }
});
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})
